package com.supreme.studyserver.component;

import com.supreme.studyserver.entity.Admin;
import com.supreme.studyserver.interfacepkg.IUser;
import com.supreme.studyserver.entity.Role;
import com.supreme.studyserver.entity.User;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class AuthConfig {

    @Bean("authRole")
    public Role role() {
        return new Role() {{
            setRoleName("admin role");
            setRoleType(99);
        }};
    }

//    @Bean(value = "qumUser")
    @Bean(value = "qumUser", initMethod = "initUser", destroyMethod = "destroyUser")
    public IUser user() {
        return new User() {{
            setUsername("user");
            setPassword("123456");
            setGender(1);
            setBirthday(new Date());
        }};
    }

//    @Bean(value = "adminUser")
    @Bean(value = "adminUser", initMethod = "initUser", destroyMethod = "destroyUser")
    public IUser admin() {
        return new Admin() {{
            setUsername("admin");
            setPassword("123456");
        }};
    }

    @Bean("seniorUser")
    public User senior() {
        return new User() {{
            setUsername("senior");
            setPassword("654321");
            setGender(2);
            setBirthday(new Date());
        }};
    }
}
